import http from "@/utils/http";
import { AxiosRequestConfig } from "axios";

export interface GetUser_ {
  /**
   * @description name
   */
  name?: string;
}
export interface GetUserByName_ {
  /**
   * @description name
   */
  name: string;
}

export class UserInfoService {
  /**
   * 支持用户搜索下拉框的查询接口。提供可选模糊名称的条件查询能力，返回简要的用户数据
   *
   * @tags 获取客户controller
   * @request GET: /user
   * @secure
   */
  getUser = (query: { name?: string } | GetUser_, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityListOptionVO>({
      url: `/user`,
      method: "GET",
      params: query,
      ...params,
    });

  /**
   * 搜索角色列表，支持角色搜索下拉框。
   *
   * @tags 获取客户controller
   * @request GET: /user/roles
   * @secure
   */
  getUserRoles = (params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityListOptionVO>({
      url: `/user/roles`,
      method: "GET",
      ...params,
    });

  /**
   * 模糊匹配userName
   *
   * @tags 获取客户controller
   * @request GET: /user/{name}
   * @deprecated
   * @secure
   */
  getUserByName = ({ name }: { name: string } | GetUserByName_, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityListOptionVO>({
      url: `/user/${name}`,
      method: "GET",
      ...params,
    });
}

export default new UserInfoService();
